﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="原料到货记录管理.aspx.cs" Inherits="syc.Store.原料到货记录管理" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">

    protected void Button_Export_Click(object sender, EventArgs e)
    {

        string part1 =
@"<html xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:x='urn:schemas-microsoft-com:office:excel'
xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<meta http-equiv=Content-Type content='text/html; charset=utf-8'>
<style>
<!--table
@page
{mso-header-data:;
mso-footer-data:;
margin:.79in .31in .79in .31in;
mso-header-margin:.51in;
mso-footer-margin:.51in;
mso-page-orientation:landscape;
mso-horizontal-page-align:center;
}
-->
</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>" + this.GongHuo.SelectedItem.Text + @"</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:Print>
      <x:ValidPrinterInfo/>
      <x:Scale>100</x:Scale>
      <x:PaperSizeIndex>9</x:PaperSizeIndex>
      <x:HorizontalResolution>200</x:HorizontalResolution>
      <x:VerticalResolution>200</x:VerticalResolution>
     </x:Print>
     <x:Selected/>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>0</x:ActiveRow>
       <x:ActiveCol>0</x:ActiveCol>
      </x:Pane>
     </x:Panes>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
 </x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body>";
        string part2 =
@"<style>
tr{height:30px;}
td{text-align:center;font-size:12pt;border:.5pt solid black;font-family:宋体;}
td.nb{border:none;}
</style>
<table border=0 cellpadding=0 style=border-collapse:collapse>
<tr>
<td width=120>日期</td>
<td width=100>车号</td>
<td width=100>质保书量</td>
<td width=100>磅重1</td>
<td width=100>磅重2</td>
<td width=100>磅重合计</td>
<td width=80>支数</td>
<td width=100>分厂</td>
<td width=80>区域</td>
<td width=90>磅差</td>
</tr>";
        string foot = @"</table></body></html>";


        Response.Charset = "utf-8";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.ContentType = "application/ms-excel";
        Response.AddHeader("content-disposition", "attachment; filename=\"" + Server.UrlEncode(this.GongHuo.SelectedItem.Text) + ".xls\"");

        Response.Write(part1);
        Response.Write(part2);


        SqlConnection Conn = new SqlConnection();
        Conn.ConnectionString = ConfigurationManager.ConnectionStrings["SCMConnectionString1"].ConnectionString;
        Conn.Open();
        SqlCommand Cmd = new SqlCommand();
        Cmd.Connection = Conn;
        Cmd.CommandText = sql + this.GetState() + " order by t1.日期";

        SqlDataReader Reader = Cmd.ExecuteReader();

        decimal biaozhongheji = 0;
        decimal bangzhongheji = 0;
        decimal zhishuheji = 0;
        while (Reader.Read())
        {
            Response.Write("<tr><td>" + ((DateTime)Reader["日期"]).ToString("yyyy-MM-dd")
                + "</td><td>" + (string)Reader["车号"]
                + "</td><td>" + ((decimal)Reader["标重"])
                + "</td><td>" + ((decimal)Reader["磅重1"])
                + "</td><td>" + ((decimal)Reader["磅重2"])
                + "</td><td>" + ((decimal)Reader["磅重"])
                + "</td><td>" + ((int)Reader["支数"])
                + "</td><td>" + (string)Reader["分厂"]
                + "</td><td>" + (int)Reader["库区"]
                + "</td><td>" + ((decimal)Reader["磅重"] - (decimal)Reader["标重"])
                + "</td></tr>");
            biaozhongheji += (decimal)Reader["标重"];
            bangzhongheji += (decimal)Reader["磅重"];
            zhishuheji += (int)Reader["支数"];
        }

        Reader.Close();
        Conn.Close();
        Reader.Dispose();
        Cmd.Dispose();
        Conn.Dispose();

        Response.Write("<tr><td>合计：</td><td></td><td>" + biaozhongheji
            + "</td><td></td><td></td><td>"
            + bangzhongheji + "</td><td>"
            + zhishuheji + "</td><td></td><td></td><td>"
            + (bangzhongheji - biaozhongheji) + "</td></tr>");

        Response.Write(foot);
        Response.End();
    }
</script>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
DeleteCommand="delete from 原料到发明细 where 记录ID=@ID;delete from 原料到货记录 where ID=@ID and 状态=0;"
>
<DeleteParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
</DeleteParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="select 0 as ID,'全部' as 名称 union all select ID, 名称 FROM 原料供货单位"></asp:SqlDataSource>



<div id="wintop" class="wintop">原料到货记录管理</div>
<asp:Panel ID="Panel1" runat="server" CssClass="panel" Visible="false">    
    <asp:Button ID="Button_Sign" runat="server" Text="到货登记" CssClass="button62"  
            UseSubmitBehavior="False" onclick="Button_Sign_Click" />
    <asp:Button ID="Button_Edit" runat="server" Text="查 看" CssClass="button75"  
        UseSubmitBehavior="False" Enabled="false" onclick="Button_Edit_Click"/>
    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="button62"  
        UseSubmitBehavior="False" 
        onclick="Button_Delete_Click"
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" />
    <asp:Button ID="Button_Post" runat="server" Text="送 检" CssClass="button62"  
            UseSubmitBehavior="False" onclick="Button_Post_Click"/>
    <asp:Button ID="Button_CancelPost" runat="server" Text="取消送检" CssClass="button62"  
            UseSubmitBehavior="False" onclick="Button_CancelPost_Click"/>
    <asp:Button ID="Button_Pass" runat="server" Text="判定合格" CssClass="button62"  
            UseSubmitBehavior="False" onclick="Button_Pass_Click"/>
    <asp:Button ID="Button_CancelPass" runat="server" Text="取消判定" CssClass="button62"  
            UseSubmitBehavior="False" onclick="Button_CancelPass_Click"/>

    <asp:Button ID="Button_In" runat="server" Text="入库单" CssClass="button62"  
        UseSubmitBehavior="False" onclick="Button_In_Click" />

    <asp:Button ID="Button_Send" runat="server" Text="发 货" CssClass="button62" Visible="true"
            UseSubmitBehavior="False" onclick="Button_Send_Click"/>
    <asp:Button ID="Button_CancelSend" runat="server" Text="取消发货" CssClass="button62"   Visible="false"
            UseSubmitBehavior="False" onclick="Button_CancelSend_Click"/>
            
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="原料到货记录查询">
<!-- =================================================================================================== -->
<!-- ========                               原料类别列表                                     =========== -->
<!-- ========                                                                               =========== -->
<!-- =================================================================================================== -->
<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="SELECT [ID],[品名]+' '+[钢级]+' '+[规格] AS 名称 FROM [原料]"></asp:SqlDataSource>
原料：
<asp:DropDownList ID="LeiBie" runat="server" Width="250px" Font-Size="12px" DataSourceID="SqlDataSource3" 
                               DataTextField="名称" DataValueField="ID" onselectedindexchanged="LeiBie_SelectedIndexChanged">
</asp:DropDownList>
<!-- =================================================================================================== -->
<span style="margin-left:8px;"></span>供货单位：<asp:DropDownList 
    ID="GongHuo" runat="server" DataSourceID="SqlDataSource2"  Width="121px"
    DataTextField="名称" DataValueField="ID"></asp:DropDownList>

<span style="margin-left:8px;"></span>使用单位：<asp:DropDownList ID="FenChang" Width="121px"
    runat="server">
    <asp:ListItem Text="全部" Value="0"></asp:ListItem>
    <asp:ListItem Text="一分厂" Value="1"></asp:ListItem>
    <asp:ListItem Text="二分厂" Value="2"></asp:ListItem>
    <asp:ListItem Text="三分厂" Value="3"></asp:ListItem>
    <asp:ListItem Text="四分厂" Value="4"></asp:ListItem>
    <asp:ListItem Text="五分厂" Value="5"></asp:ListItem>
</asp:DropDownList>
<span style="margin-left:8px;"></span>库区：<asp:TextBox ID="KuQu" runat="server" CssClass="textbox" Width="60px"></asp:TextBox>

<div style="font-size:6px;height:6px;line-height:6px;"></div>
状态筛选：<asp:DropDownList ID="XianShi" runat="server" Width="200px">
<asp:ListItem Value="">全部显示记录</asp:ListItem>
<asp:ListItem Value="0">仅显示未送检记录</asp:ListItem>
<asp:ListItem Value="1">仅显示待检记录</asp:ListItem>
<asp:ListItem Value="2">仅显示合格记录</asp:ListItem>
<asp:ListItem Value="21">仅显示合格未入库记录</asp:ListItem>
</asp:DropDownList>
<span style="margin-left:8px;"></span>起始日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="margin-left:8px;"></span>截止日期：<asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />

<span style="margin-left:5px;"></span><asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Query_Click" />
<asp:Button ID="Button_Export" runat="server" Text="导 出" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Export_Click"/>
        
<asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Reset_Click" />
</asp:Panel>

<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title"><div style="float:left;margin-top:3px;">原料到货记录</div><div style="float:right;font-weight:normal">
                    重量单位：吨 <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10">10 项/页</asp:ListItem>
                    <asp:ListItem Value="20" Selected="True">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    <asp:ListItem Value="500">500 项/页</asp:ListItem>
                    <asp:ListItem Value="1000">1000 项/页</asp:ListItem>
                    </asp:DropDownList>
                    
                    </div>
	            </td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID,状态,入库单" 
                        DataSourceID="SqlDataSource1"
                        PageSize="20"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" >
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <asp:CheckBox ID="Check_All" runat="server" AutoPostBack="true"
                                        oncheckedchanged="Check_All_CheckedChanged" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="Check_Item" runat="server" AutoPostBack="true" 
                                        oncheckedchanged="Check_Item_CheckedChanged"/>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="24px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="车号">
                                <ItemTemplate>
                                    <asp:Label ID="Label_ch" runat="server" Text='<%# Eval("车号") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="品名" SortExpression="原料ID">
                                <ItemTemplate>
                                    <asp:Label ID="Label_pm" runat="server" Text='<%# Eval("原料") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="供货单位" SortExpression="供货ID">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gh" runat="server" Text='<%# Eval("供货单位") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="磅重1">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bz1" runat="server" Text='<%# Eval("磅重1") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="磅重2">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bz2" runat="server" Text='<%# Eval("磅重2") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="磅重合计">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bz" runat="server" Text='<%# Eval("磅重") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="质保书量">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zbz" runat="server" Text='<%# Eval("标重") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField> 
                            
                            <asp:TemplateField HeaderText="磅差">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bc" runat="server" Text='<%# (decimal)Eval("磅重")- (decimal)Eval("标重") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField> 
                            
                            <asp:TemplateField HeaderText="支数">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zs" runat="server" Text='<%# Eval("支数") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="分厂">
                                <ItemTemplate>
                                    <asp:Label ID="Label_fc" runat="server" Text='<%# Eval("分厂") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="库区">
                                <ItemTemplate>
                                    <asp:Label ID="Label_kq" runat="server" Text='<%# Eval("库区") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="40px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="明细">
                                <ItemTemplate>
                                    <asp:Label ID="Label_mx" runat="server" Text='<%# Eval("明细") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="40px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="日期" SortExpression="日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dh" runat="server" Text='<%# Eval("日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="状态" ItemStyle-BackColor="#ff6600" ItemStyle-ForeColor="#ffffff"  SortExpression="状态">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zt" runat="server" Text='<%# Eval("状态描述") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                                                          
                            <asp:TemplateField HeaderText="入库单" SortExpression="入库单">
                                <ItemTemplate>
                                    <asp:Label ID="Label_rkd" runat="server" Text='<%# Eval("入库单","{0:D7}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="质检员">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zj" runat="server" Text='<%# Eval("质检员") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>       
                            <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                        <input id="mxbu" type="button" value="验收记录" class="smallbutton" 
                                        onclick="parent.swin2_load('/ZhiJian/新原料入厂验收记录.aspx?ch=<%#Eval("车号") %>&&pm=<%#Eval("原料ID") %>&&ghs=<%#Eval("供货单位") %>&&pd=<%#Eval("状态") %>&&rq=<%# Eval("判定日期") %>&&pdy=<%# Eval("质检员") %>&&bl=<%# Eval("磅重") %>&&zs=<%# Eval("支数") %>',780,1000,'yes');" />
                                    </ItemTemplate>
                            </asp:TemplateField>                
                            <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                         <input id="mxbu" type="button" value="复验单" class="smallbutton" 
                                         onclick="parent.swin2_load('/zhijian/原材料复检判定单.aspx?ch=<%#Eval("车号") %>&&pm=<%#Eval("原料ID") %>&&ghs=<%#Eval("供货单位") %>&&pd=<%#Eval("状态") %>&&rq=<%# Eval("判定日期") %>&&pdy=<%# Eval("质检员") %>&&bl=<%# Eval("磅重") %>&&zs=<%# Eval("支数") %>',720,600);" />
                                    </ItemTemplate>
                            </asp:TemplateField>   
                            
                            <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                        <input id="mxbu" type="button" value="质保书" class="smallbutton" 
                                        onclick="parent.swin2_load('/ZhiJian/接箍质保书.aspx?ID=<%#Eval("ID") %>',1024,1000,'yes');" />
                                    </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                 
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script>
       parent.hidesubmenu(true);

    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
        }
        if (rows[i].className == "grid-row-normal"
        || rows[i].className == "grid-row-bright"
        || rows[i].className == "grid-row-selected") {
            rows[i].onclick = selectRow;
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }
    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0,sum3=0;
    var col = 6;
    if (rows[0].cells.length == 14) col = 6;
    for (i = 1; i < rows.length; i++) {
        sum1 += (Number(rows[i].cells[col].innerText)* 1000)/1000;
        sum2 += (Number(rows[i].cells[col + 1].innerText) * 1000) / 1000;
        sum3 += (Number(rows[i].cells[col+3].innerText) * 1000) / 1000;
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += "　　本页小计：" + (rows.length - 1) + " 项   磅重汇总：" + fixFloatZ(sum1, 3) + " 吨 标量汇总：" + fixFloatZ(sum2, 3) + " 吨 支数汇总："+sum3+" 支";
    
</script>
</body>
</html>
